﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/BackendMain.master"
    AutoEventWireup="true" CodeFile="EmployeeList.aspx.cs" Inherits="Backend_EmployeeList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table>
        <tr>
            <td>
                Employee Name:
                <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td>
                Username:
                <asp:TextBox ID="txtUsername" runat="server"></asp:TextBox>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td>
                Password:
                <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
            </td>
        </tr>
        <tr>
            <td>
                Employee List:
            </td>
        </tr>
        <tr>
            <td>
                <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                    DataKeyNames="Id" DataSourceID="SqlDataSource1" AllowPaging="True" 
                    PageSize="50">
                    <Columns>
                        <asp:CommandField ShowEditButton="True" />
                        <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id"
                            Visible="false" />
                        <asp:BoundField DataField="EmployeeName" HeaderText="EmployeeName" SortExpression="EmployeeName" />
                        <asp:BoundField DataField="EmployeeNo" Visible="false" HeaderText="EmployeeNo" SortExpression="EmployeeNo" />
                        <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
                        <asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" />
                        <asp:BoundField DataField="CreateTime" HeaderText="CreateTime" SortExpression="CreateTime" />
                        <asp:BoundField DataField="UpdateTime" HeaderText="UpdateTime" SortExpression="UpdateTime" />
                        <asp:CheckBoxField DataField="IsDeleted" HeaderText="IsDeleted" SortExpression="IsDeleted" />
                        <asp:TemplateField>
                            <ItemTemplate>
                                <a runat="server" target="_blank" href=<%# "Report.aspx?userid=" + Eval("Id") %> >Details</a>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </td>
        </tr>
    </table>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EmployeeTrackingConnectionString %>"
        InsertCommand="INSERT INTO [EtEmployeeInfo] ([Id], [EmployeeName], [EmployeeNo], [Username], [Password], [CreateTime], [UpdateTime], [IsDeleted]) VALUES (@Id, @EmployeeName, @EmployeeNo, @Username, @Password, @CreateTime, @UpdateTime, @IsDeleted)"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [EtEmployeeInfo]"
        UpdateCommand="UPDATE [EtEmployeeInfo] SET [EmployeeName] = @EmployeeName, [EmployeeNo] = @EmployeeNo, [Username] = @Username, [Password] = @Password, [CreateTime] = @CreateTime, [UpdateTime] = @UpdateTime, [IsDeleted] = @IsDeleted WHERE [Id] = @original_Id"
        DeleteCommand="DELETE FROM [EtEmployeeInfo] WHERE [Id] = @original_Id">
        <DeleteParameters>
            <asp:Parameter Name="original_Id" Type="Object" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Id" Type="Object" />
            <asp:Parameter Name="EmployeeName" Type="String" />
            <asp:Parameter Name="EmployeeNo" Type="Int32" />
            <asp:Parameter Name="Username" Type="String" />
            <asp:Parameter Name="Password" Type="String" />
            <asp:Parameter Name="CreateTime" Type="DateTime" />
            <asp:Parameter Name="UpdateTime" Type="DateTime" />
            <asp:Parameter Name="IsDeleted" Type="Boolean" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="EmployeeName" Type="String" />
            <asp:Parameter Name="EmployeeNo" Type="Int32" />
            <asp:Parameter Name="Username" Type="String" />
            <asp:Parameter Name="Password" Type="String" />
            <asp:Parameter Name="CreateTime" Type="DateTime" />
            <asp:Parameter Name="UpdateTime" Type="DateTime" />
            <asp:Parameter Name="IsDeleted" Type="Boolean" />
            <asp:Parameter Name="original_Id" Type="Object" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>
